package com.eastfair.venueservice.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.eastfair.core.base.entity.Entity;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.eastfair.database.mybatis.typehandler.M9EncryptHandler;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.venueservice.enumeration.ServiceOrderPayStatusEnum;
import com.eastfair.venueservice.enumeration.ServiceOrderWorkOrderStatusEnum;
import com.eastfair.venueservice.enumeration.ServiceOrderInvoiceStatusEnum;
import com.eastfair.venueservice.enumeration.ServiceOrderOrderSourceEnum;
import com.eastfair.venueservice.enumeration.ServiceOrderServiceReportVenueStatusEnum;
import com.eastfair.venueservice.enumeration.ServiceOrderOrderStatusEnum;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 服务订单
 * </p>
 *
 * @author dqq
 * @since 2023-05-16
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value="vsm_service_order",autoResultMap = true)
@ApiModel(value = "ServiceOrder", description = "服务订单")
@AllArgsConstructor
public class ServiceOrder extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用（确认状态）：1是 已确认；0否 未确认
     */
    @ApiModelProperty(value = "是否启用（确认状态）：1是 已确认；0否 未确认")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用（确认状态）：1是 已确认；0否 未确认")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 订单编号
     */
    @ApiModelProperty(value = "订单编号")
    @Size(max = 64, message = "订单编号长度不能超过64")
    @TableField(value = "order_number", condition = LIKE)
    @Excel(name = "订单编号")
    private String orderNumber;

    /**
     * 报修订单关联的报修单号
     */
    @ApiModelProperty(value = "报修订单关联的报修单号")
    @Size(max = 64, message = "报修订单关联的报修单号长度不能超过64")
    @TableField(value = "repair_report_number", condition = LIKE)
    @Excel(name = "报修订单关联的报修单号")
    private String repairReportNumber;

    /**
     * 订单总金额
     */
    @ApiModelProperty(value = "订单总金额")
    @TableField(value = "total_amount")
    @Excel(name = "订单总金额")
    private BigDecimal totalAmount;

    /**
     * 附加费金额
     */
    @ApiModelProperty(value = "附加费金额")
    @TableField(value = "surcharge")
    @Excel(name = "附加费金额")
    private BigDecimal surcharge;

    /**
     * 订单状态 #{NOT_SUBMIT:未提交;SUBMIT:已提交;PARTIAL_REPORT_VENUE:部分报馆;HAS_REPORT_VENUE:已报馆;DISPATCH:已派单;RECEIVE:已接单;COMPLETE:已完成;CANCEL:已取消}
     */
    @ApiModelProperty(value = "订单状态 #{NOT_SUBMIT:未提交;SUBMIT:已提交;PARTIAL_REPORT_VENUE:部分报馆;HAS_REPORT_VENUE:已报馆;DISPATCH:已派单;RECEIVE:已接单;COMPLETE:已完成;CANCEL:已取消}")
    @TableField(value = "order_status")
    @Excel(name = "订单状态 #{NOT_SUBMIT:未提交;SUBMIT:已提交;PARTIAL_REPORT_VENUE:部分报馆;HAS_REPORT_VENUE:已报馆;DISPATCH:已派单;RECEIVE:已接单;COMPLETE:已完成;CANCEL:已取消}", replace = {"未提交_NOT_SUBMIT", "已提交_SUBMIT", "部分报馆_PARTIAL_REPORT_VENUE", "已报馆_HAS_REPORT_VENUE", "已派单_DISPATCH", "已接单_RECEIVE", "已完成_COMPLETE", "已取消_CANCEL",  "_null"})
    private ServiceOrderOrderStatusEnum orderStatus;

    /**
     * 订单来源 #{ONLINE_BOOK:线上预定;ON_SITE_ORDER:现场预定;REPORT_ORDER:报馆订单;WORK_OVERTIME_ORDER:加班订单;BUILDER_REPORT:搭建商报馆订单;BUILDER_ONLINE_BOOK:搭建商线上预定;HOME_BUILDER_ORDER:主场预定的搭建商订单;HOME_EXHIBITOR_ORDER:主场预定的展商订单;VENUE_HOME_REPAIR_ORDER:场馆给主场下发的保修订单;HOME_BUILDER_REPAIR_ORDER:主场给搭建商下发的报修订单;SPONSOR_ORDER:主办预定订单}
     */
    @ApiModelProperty(value = "订单来源 #{ONLINE_BOOK:线上预定;ON_SITE_ORDER:现场预定;REPORT_ORDER:报馆订单;WORK_OVERTIME_ORDER:加班订单;BUILDER_REPORT:搭建商报馆订单;BUILDER_ONLINE_BOOK:搭建商线上预定;HOME_BUILDER_ORDER:主场预定的搭建商订单;HOME_EXHIBITOR_ORDER:主场预定的展商订单;VENUE_HOME_REPAIR_ORDER:场馆给主场下发的保修订单;HOME_BUILDER_REPAIR_ORDER:主场给搭建商下发的报修订单;SPONSOR_ORDER:主办预定订单}")
    @TableField(value = "order_source")
    @Excel(name = "订单来源 #{ONLINE_BOOK:线上预定;ON_SITE_ORDER:现场预定;REPORT_ORDER:报馆订单;WORK_OVERTIME_ORDER:加班订单;BUILDER_REPORT:搭建商报馆订单;BUILDER_ONLINE_BOOK:搭建商线上预定;HOME_BUILDER_ORDER:主场预定的搭建商订单;HOME_EXHIBITOR_ORDER:主场预定的展商订单;VENUE_HOME_REPAIR_ORDER:场馆给主场下发的保修订单;HOME_BUILDER_REPAIR_ORDER:主场给搭建商下发的报修订单;SPONSOR_ORDER:主办预定订单}", replace = {"线上预定_ONLINE_BOOK", "现场预定_ON_SITE_ORDER", "报馆订单_REPORT_ORDER", "加班订单_WORK_OVERTIME_ORDER", "搭建商报馆订单_BUILDER_REPORT", "搭建商线上预定_BUILDER_ONLINE_BOOK", "主场预定的搭建商订单_HOME_BUILDER_ORDER", "主场预定的展商订单_HOME_EXHIBITOR_ORDER", "场馆给主场下发的保修订单_VENUE_HOME_REPAIR_ORDER", "主场给搭建商下发的报修订单_HOME_BUILDER_REPAIR_ORDER", "主办预定订单_SPONSOR_ORDER",  "_null"})
    private ServiceOrderOrderSourceEnum orderSource;

    /**
     * 订单时间
     */
    @ApiModelProperty(value = "订单时间")
    @TableField(value = "order_time")
    @Excel(name = "订单时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime orderTime;

    /**
     * 是否是管理费订单(0:否, 1:是)
     */
    @ApiModelProperty(value = "是否是管理费订单(0:否, 1:是)")
    @TableField(value = "is_manage_expense")
    @Excel(name = "是否是管理费订单(0:否, 1:是)")
    private Integer isManageExpense;

    /**
     * 展会ID
     */
    @ApiModelProperty(value = "展会ID")
    @TableField(value = "exhibition_manage_id")
    @Excel(name = "展会ID")
    private Long exhibitionManageId;

    /**
     * 展会名称
     */
    @ApiModelProperty(value = "展会名称")
    @Size(max = 64, message = "展会名称长度不能超过64")
    @TableField(value = "exhibition_manage_name", condition = LIKE)
    @Excel(name = "展会名称")
    private String exhibitionManageName;

    /**
     * 企业ID
     */
    @ApiModelProperty(value = "企业ID")
    @TableField(value = "company_id")
    @Excel(name = "企业ID")
    private Long companyId;

    /**
     * 公司编码
     */
    @ApiModelProperty(value = "公司编码")
    @Size(max = 64, message = "公司编码长度不能超过64")
    @TableField(value = "company_code", condition = LIKE)
    @Excel(name = "公司编码")
    private String companyCode;

    /**
     * 展商ID
     */
    @ApiModelProperty(value = "展商ID")
    @TableField(value = "exhibitor_id")
    @Excel(name = "展商ID")
    private Long exhibitorId;

    /**
     * 展商名称
     */
    @ApiModelProperty(value = "展商名称")
    @Size(max = 64, message = "展商名称长度不能超过64")
    @TableField(value = "exhibitor_name", condition = LIKE)
    @Excel(name = "展商名称")
    private String exhibitorName;

    /**
     * 公司名称
     */
    @ApiModelProperty(value = "公司名称")
    @Size(max = 200, message = "公司名称长度不能超过200")
    @TableField(value = "company_name", condition = LIKE)
    @Excel(name = "公司名称")
    private String companyName;

    /**
     * 公司类型
     */
    @ApiModelProperty(value = "公司类型")
    @Size(max = 64, message = "公司类型长度不能超过64")
    @TableField(value = "company_type", condition = LIKE)
    @Excel(name = "公司类型")
    private String companyType;

    /**
     * 联系人
     */
    @ApiModelProperty(value = "联系人")
    @Size(max = 100, message = "联系人长度不能超过100")
    @TableField(value = "contact", condition = LIKE)
    @Excel(name = "联系人")
    private String contact;

    /**
     * 联系方式
     */
    @ApiModelProperty(value = "联系方式")
    @Size(max = 1024, message = "联系方式长度不能超过1024")
    @TableField(value = "phone", condition = LIKE,typeHandler = M9EncryptHandler.class)
    @Excel(name = "联系方式")
    private String phone;

    /**
     * 展厅编码
     */
    @ApiModelProperty(value = "展厅编码")
    @Size(max = 64, message = "展厅编码长度不能超过64")
    @TableField(value = "space_code", condition = LIKE)
    @Excel(name = "展厅编码")
    private String spaceCode;

    /**
     * 展厅号
     */
    @ApiModelProperty(value = "展厅号")
    @Size(max = 100, message = "展厅号长度不能超过100")
    @TableField(value = "space_name", condition = LIKE)
    @Excel(name = "展厅号")
    private String spaceName;

    /**
     * 展位号
     */
    @ApiModelProperty(value = "展位号")
    @Size(max = 100, message = "展位号长度不能超过100")
    @TableField(value = "site_name", condition = LIKE)
    @Excel(name = "展位号")
    private String siteName;

    /**
     * 应付金额
     */
    @ApiModelProperty(value = "应付金额")
    @TableField(value = "should_pay_amount")
    @Excel(name = "应付金额")
    private BigDecimal shouldPayAmount;

    /**
     * 实际支付金额
     */
    @ApiModelProperty(value = "实际支付金额")
    @TableField(value = "actual_pay_amount")
    @Excel(name = "实际支付金额")
    private BigDecimal actualPayAmount;

    /**
     * 优惠金额
     */
    @ApiModelProperty(value = "优惠金额")
    @TableField(value = "discount_amount")
    @Excel(name = "优惠金额")
    private BigDecimal discountAmount;

    /**
     * 支付方式
     */
    @ApiModelProperty(value = "支付方式")
    @Size(max = 64, message = "支付方式长度不能超过64")
    @TableField(value = "pay_way", condition = LIKE)
    @Excel(name = "支付方式")
    private String payWay;

    /**
     * 支付时间
     */
    @ApiModelProperty(value = "支付时间")
    @TableField(value = "pay_time")
    @Excel(name = "支付时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime payTime;

    /**
     * 支付状态 #{NOT_PAY:未付款;HAS_PAY:已付款;PARTIAL_PAY:部分付款;SETTLE_AFTER_EXHIBITION:会后结算;REFUND_APPLIED:已申请退款;REFUNDING:退款中;HAS_REFUND:已退款;REFUND_REJECT:退款驳回}
     */
    @ApiModelProperty(value = "支付状态 #{NOT_PAY:未付款;HAS_PAY:已付款;PARTIAL_PAY:部分付款;SETTLE_AFTER_EXHIBITION:会后结算;REFUND_APPLIED:已申请退款;REFUNDING:退款中;HAS_REFUND:已退款;REFUND_REJECT:退款驳回}")
    @TableField(value = "pay_status")
    @Excel(name = "支付状态 #{NOT_PAY:未付款;HAS_PAY:已付款;PARTIAL_PAY:部分付款;SETTLE_AFTER_EXHIBITION:会后结算;REFUND_APPLIED:已申请退款;REFUNDING:退款中;HAS_REFUND:已退款;REFUND_REJECT:退款驳回}", replace = {"未付款_NOT_PAY", "已付款_HAS_PAY", "部分付款_PARTIAL_PAY", "会后结算_SETTLE_AFTER_EXHIBITION", "已申请退款_REFUND_APPLIED", "退款中_REFUNDING", "已退款_HAS_REFUND", "退款驳回_REFUND_REJECT",  "_null"})
    private ServiceOrderPayStatusEnum payStatus;

    /**
     * 退款状态
     */
    @ApiModelProperty(value = "退款状态")
    @Size(max = 64, message = "退款状态长度不能超过64")
    @TableField(value = "refund_status", condition = LIKE)
    @Excel(name = "退款状态")
    private String refundStatus;

    /**
     * 退款时间
     */
    @ApiModelProperty(value = "退款时间")
    @TableField(value = "refund_time")
    @Excel(name = "退款时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime refundTime;

    /**
     * 退款方式
     */
    @ApiModelProperty(value = "退款方式")
    @Size(max = 64, message = "退款方式长度不能超过64")
    @TableField(value = "refund_way", condition = LIKE)
    @Excel(name = "退款方式")
    private String refundWay;

    /**
     * 退款金额
     */
    @ApiModelProperty(value = "退款金额")
    @TableField(value = "refund_amount")
    @Excel(name = "退款金额")
    private BigDecimal refundAmount;

    /**
     * 工单状态 #{NOT_DISPATCH:未派单;HAS_DISPATCH:已派单;HAS_RECEIVE:已接单;PARTIAL_COMPLETE:部分完成;COMPLETE:已完成;REVOKE:已撤销;CANCEL:已作废}
     */
    @ApiModelProperty(value = "工单状态 #{NOT_DISPATCH:未派单;HAS_DISPATCH:已派单;HAS_RECEIVE:已接单;PARTIAL_COMPLETE:部分完成;COMPLETE:已完成;REVOKE:已撤销;CANCEL:已作废}")
    @TableField(value = "work_order_status")
    @Excel(name = "工单状态 #{NOT_DISPATCH:未派单;HAS_DISPATCH:已派单;HAS_RECEIVE:已接单;PARTIAL_COMPLETE:部分完成;COMPLETE:已完成;REVOKE:已撤销;CANCEL:已作废}", replace = {"未派单_NOT_DISPATCH", "已派单_HAS_DISPATCH", "已接单_HAS_RECEIVE", "部分完成_PARTIAL_COMPLETE", "已完成_COMPLETE", "已撤销_REVOKE", "已作废_CANCEL",  "_null"})
    private ServiceOrderWorkOrderStatusEnum workOrderStatus;

    /**
     * 派单时间
     */
    @ApiModelProperty(value = "派单时间")
    @TableField(value = "dispatch_work_order_time")
    @Excel(name = "派单时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime dispatchWorkOrderTime;

    /**
     * 交易完成时间
     */
    @ApiModelProperty(value = "交易完成时间")
    @TableField(value = "finish_order_time")
    @Excel(name = "交易完成时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime finishOrderTime;

    /**
     * 搭建商订单服务报馆状态 #{NOT_REPORT:未报馆;PARTIAL_REPORT:部分报馆;HAS_REPORT:已报馆;NOT_NEED_REPORT:无需报馆}
     */
    @ApiModelProperty(value = "搭建商订单服务报馆状态 #{NOT_REPORT:未报馆;PARTIAL_REPORT:部分报馆;HAS_REPORT:已报馆;NOT_NEED_REPORT:无需报馆}")
    @TableField(value = "service_report_venue_status")
    @Excel(name = "搭建商订单服务报馆状态 #{NOT_REPORT:未报馆;PARTIAL_REPORT:部分报馆;HAS_REPORT:已报馆;NOT_NEED_REPORT:无需报馆}", replace = {"未报馆_NOT_REPORT", "部分报馆_PARTIAL_REPORT", "已报馆_HAS_REPORT", "无需报馆_NOT_NEED_REPORT",  "_null"})
    private ServiceOrderServiceReportVenueStatusEnum serviceReportVenueStatus;

    /**
     * 开票状态 #{NOT_APPLIED:未申请;REQUESTED:已申请;INVOICED:已开票;REJECTED:被驳回}
     */
    @ApiModelProperty(value = "开票状态 #{NOT_APPLIED:未申请;REQUESTED:已申请;INVOICED:已开票;REJECTED:被驳回}")
    @TableField(value = "invoice_status")
    @Excel(name = "开票状态 #{NOT_APPLIED:未申请;REQUESTED:已申请;INVOICED:已开票;REJECTED:被驳回}", replace = {"未申请_NOT_APPLIED", "已申请_REQUESTED", "已开票_INVOICED", "被驳回_REJECTED",  "_null"})
    private ServiceOrderInvoiceStatusEnum invoiceStatus;

    /**
     * 已开票金额
     */
    @ApiModelProperty(value = "已开票金额")
    @TableField(value = "invoice_amount")
    @Excel(name = "已开票金额")
    private BigDecimal invoiceAmount;

    /**
     * 发票号码
     */
    @ApiModelProperty(value = "发票号码")
    @Size(max = 64, message = "发票号码长度不能超过64")
    @TableField(value = "invoice_number", condition = LIKE)
    @Excel(name = "发票号码")
    private String invoiceNumber;

    /**
     * 发票代码
     */
    @ApiModelProperty(value = "发票代码")
    @Size(max = 100, message = "发票代码长度不能超过100")
    @TableField(value = "invoice_code", condition = LIKE)
    @Excel(name = "发票代码")
    private String invoiceCode;

    /**
     * 订单归属系统
     */
    @ApiModelProperty(value = "订单归属系统")
    @Size(max = 64, message = "订单归属系统长度不能超过64")
    @TableField(value = "belong_system", condition = LIKE)
    @Excel(name = "订单归属系统")
    private String belongSystem;

    /**
     * 备注信息
     */
    @ApiModelProperty(value = "备注信息")
    @Size(max = 500, message = "备注信息长度不能超过500")
    @TableField(value = "remark", condition = LIKE)
    @Excel(name = "备注信息")
    private String remark;


    @Builder
    public ServiceOrder(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId, 
                    String orderNumber, String repairReportNumber, BigDecimal totalAmount, BigDecimal surcharge, ServiceOrderOrderStatusEnum orderStatus, ServiceOrderOrderSourceEnum orderSource, 
                    LocalDateTime orderTime, Integer isManageExpense, Long exhibitionManageId, String exhibitionManageName, Long companyId, String companyCode, 
                    Long exhibitorId, String exhibitorName, String companyName, String companyType, String contact, String phone, 
                    String spaceCode, String spaceName, String siteName, BigDecimal shouldPayAmount, BigDecimal actualPayAmount, BigDecimal discountAmount, 
                    String payWay, LocalDateTime payTime, ServiceOrderPayStatusEnum payStatus, String refundStatus, LocalDateTime refundTime, String refundWay, 
                    BigDecimal refundAmount, ServiceOrderWorkOrderStatusEnum workOrderStatus, LocalDateTime dispatchWorkOrderTime, LocalDateTime finishOrderTime, ServiceOrderServiceReportVenueStatusEnum serviceReportVenueStatus, ServiceOrderInvoiceStatusEnum invoiceStatus, 
                    BigDecimal invoiceAmount, String invoiceNumber, String invoiceCode, String belongSystem, String remark) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.orderNumber = orderNumber;
        this.repairReportNumber = repairReportNumber;
        this.totalAmount = totalAmount;
        this.surcharge = surcharge;
        this.orderStatus = orderStatus;
        this.orderSource = orderSource;
        this.orderTime = orderTime;
        this.isManageExpense = isManageExpense;
        this.exhibitionManageId = exhibitionManageId;
        this.exhibitionManageName = exhibitionManageName;
        this.companyId = companyId;
        this.companyCode = companyCode;
        this.exhibitorId = exhibitorId;
        this.exhibitorName = exhibitorName;
        this.companyName = companyName;
        this.companyType = companyType;
        this.contact = contact;
        this.phone = phone;
        this.spaceCode = spaceCode;
        this.spaceName = spaceName;
        this.siteName = siteName;
        this.shouldPayAmount = shouldPayAmount;
        this.actualPayAmount = actualPayAmount;
        this.discountAmount = discountAmount;
        this.payWay = payWay;
        this.payTime = payTime;
        this.payStatus = payStatus;
        this.refundStatus = refundStatus;
        this.refundTime = refundTime;
        this.refundWay = refundWay;
        this.refundAmount = refundAmount;
        this.workOrderStatus = workOrderStatus;
        this.dispatchWorkOrderTime = dispatchWorkOrderTime;
        this.finishOrderTime = finishOrderTime;
        this.serviceReportVenueStatus = serviceReportVenueStatus;
        this.invoiceStatus = invoiceStatus;
        this.invoiceAmount = invoiceAmount;
        this.invoiceNumber = invoiceNumber;
        this.invoiceCode = invoiceCode;
        this.belongSystem = belongSystem;
        this.remark = remark;
    }

}
